﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QunProject.Common
{
    /// <summary>
    /// 短信帮助类
    /// </summary>
    public class SmsHelper
    {
        /// <summary>
        /// 短信API
        /// </summary>
        private readonly string apiUrl = "http://api.jisuapi.com/sms/send?mobile={0}&content={1}&appkey={2}";
        /// <summary>
        /// 账户appKey
        /// </summary>
        private readonly string appKey = "此处填写短信appkey";

        /// <summary>
        /// 验证码短信内容
        /// </summary>
        private readonly string smsContent_sendCode = "您本次获取的验证码为{0}，有效时间两分钟，请妥善保存好验证码，我们不会以任何理由向您索取验证码。【淡云网】";

        /// <summary>
        /// 发送短信验证码
        /// </summary>
        /// <param name="phone">手机号码</param>
        /// <param name="code">验证码</param>
        /// <returns></returns>
        public string SendSms(string phone, string code)
        {
            string content = string.Format(smsContent_sendCode, code);
            string sendUrl = string.Format(apiUrl, phone, content, appKey);
            return Common.HttpHelper.HttpGet(sendUrl);
        }
    }
}
